<script type="text/javascript">
var docheckpsstatandaddvolume='__URL__/docheckpsstatandaddvolume';
</script>


<?php $i=0; ?>
 <div class='col-md-12 col-xs-12'><a class='btn btn-default' href='__URL__/query'>返回</a></div>
<div class='col-md-12 col-xs-12'>
<?php foreach($psls as $pso){ ?>

<div class="panel panel-default">
  <div class="panel-body">
    <table class='table table-hover table-striped table-bordered table-condensed' id='NBtb'>
		<thead>
			<tr style="background-color: #5bc0de;color:#fff">
				<th>序号</th>
				<th>产线</th>
				<th>部件名称</th>
				<th>部件编号</th>
				<th>计划总量</th>
				<th>已配送量</th>
				<th>线边时间</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>{++$i}</td>
				<td>{$pso[linenm]}</td>
				<td>{$pso[partnm]}</td>
				<td>{$pso[partcode]}</td>
				<td>{$pso[psvolume]}</td>
				<td id='psalready_{$pso[psid]}'>{$pso[psalready]}</td>
				<td>{$pso[xianbiantm]}</td>
				<td>{$pso[psstatnm]}</td>
				<td><a class='btn btn-info' id='complete_{$pso[psid]}' onclick="ask({$pso[psid]},{$pso[partvolumeperpa]})">完成</a></td>
				
			</tr>
			<tr>
				<td colspan="9">{$pso['str']}</td>
			</tr>
			<tr>
				<td colspan="9">
					<div class='col-md-12 col-xs-12' style="height:30px;"><div class='pull-left' style="width:{$pso[diyiduan]};background-color:#f0ad4e;height:30px;overflow:hidden;line-height:30px;color:#fff">已生产：{$pso[diyiduan]}</div><div class='pull-left' style="width:{$pso[dierduan]};background-color:#5cb85c;height:30px;overflow:hidden;line-height:30px;color:#fff">已配送：{$pso[dierduan]}</div><div class='pull-left' style="width:{$pso[disanduan]};background-color:#ccc;height:30px"></div></div>
				</td>
			</tr>
			
		</tbody>
	</table>
  </div>
</div>

<?php } ?>
</div>


<!--#################-->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal_ask" style='display: none' id='ask'>
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal" id="myModal_ask" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" style='padding-top:100px'>
    <div class="modal-content">
      <div class="modal-header">
      <button type="button" class="close close_ask" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h4 class="modal-title">请输入数量</h4>
    </div>
      <div class="modal-body" id='askcontent'>
        
		  <div class="form-group">
		    <input type="hidden" class="form-control" id="psid" >
		    <input type="telephone" class="form-control" id="peisongliang" >
		  </div>
		  
		  <button type="submit" class="btn btn-success pull-right" id='querenwancheng'>确认完成</button>
		  <div class='clearfix'></div>
		
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default close_ask" data-dismiss="modal" >关闭</button>
        
      </div>
    </div>
  </div>
</div>

<script>
var close_flag=0;//0的时候关闭就是关闭没有废话，1的时候关闭就是先关闭再刷新
function ask(psid,partvolumeperpa){
  $('#psid').val(psid);
  $('#peisongliang').val(partvolumeperpa);
  $('#ask').trigger('click');
  
  
}

$(function(){
	$('#querenwancheng').click(function(){
		var obj=new Object();
		obj['psid']=$('#psid').val();
		obj['peisongliang']=$('#peisongliang').val();
		$.ajax({
            'type': 'GET',
            'url':docheckpsstatandaddvolume,
            'async':false,  
            'contentType': 'application/json',
            'data': obj,
            'dataType': 'json',
            'success': function(data) {
            	$('#psalready_'+$('#psid').val()).html("<a style='color:#f00'>"+(parseInt($('#psalready_'+$('#psid').val()).html())+parseInt($('#peisongliang').val()))+"</a>");
				$('#complete_'+$('#psid').val()).attr('disabled','desabled');
				$('.close_ask').trigger('click');
            	console.log("success");
            },
            'error':function() {
                console.log("error");
            }
        });
	})
})

</script>